//
//  AppointmentViewController.m
//  QuickCure
//
//  Created by 凉气的Mac on 16/9/13.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "AppointmentViewController.h"

#import "AppointmentTopView.h"

#import "DoctorInfoView.h"

#import "AppointmentInfoView.h"

@interface AppointmentViewController ()


@property(nonatomic,strong)  AppointmentTopView *topView;

@end

@implementation AppointmentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationController.navigationBar.translucent = NO;
    
    self.title = @"预约医生信息详情";
    
    //设置顶部界面
    [self setupTopView];
    
    //设置预约医生界面
    [self setupAppointment];
    
    //设置底部按钮
    [self setupBottomBtn];
    
}


#pragma mark --
#pragma mark --设置顶部界面
-(void)setupTopView{

    AppointmentTopView *topView = [[AppointmentTopView alloc]init];
    
    self.topView = topView;
    
    [self.view addSubview:topView];
    
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.right.equalTo(self.view);
        
        make.height.equalTo(@90);
        
    }];
    
    [self addLineViewWithTopView:topView];
    
    
    
}

-(void)setupAppointment{
    
    //预约医生
    UILabel *appointmentLabel = [self addLabelWithString:@"预约医生:" top:self.topView];
    
    [self addLineViewWithTopView:appointmentLabel];
    
    //中间医生信息
    DoctorInfoView *doctorInfoView = [[DoctorInfoView alloc]init];
    
    [self.view addSubview:doctorInfoView];
    
    [doctorInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(appointmentLabel.mas_bottom).offset(1);
        
        make.left.right.equalTo(self.view);
        
        make.height.equalTo(@90);
        
    }];
    
    [self addLineViewWithTopView:doctorInfoView];
    
    //预约须知
    UILabel *appointmentInfoLabel = [self addLabelWithString:@"预约须知:" top:doctorInfoView];
    
    [self addLineViewWithTopView:appointmentInfoLabel];
    
    //预约须知具体信息
    AppointmentInfoView *appointmentInfoView = [[AppointmentInfoView alloc]init];
    
    [self.view addSubview:appointmentInfoView];
    
    [appointmentInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(appointmentInfoLabel.mas_bottom).offset(1);
        
        make.left.right.equalTo(self.view);
        
        make.height.equalTo(@140);
        
    }];
    
    [self addLineViewWithTopView:appointmentInfoView];
    
    
}


#pragma mark --
#pragma mark --添加label
-(UILabel *)addLabelWithString:(NSString *)string top:(UIView *)topView{
    
    UILabel *label = [[UILabel alloc]init];
    
    label.font = [UIFont systemFontOfSize:20];
    
    label.text = string;
    
    label.textColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    
    [self.view addSubview:label];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(topView.mas_bottom);
        
        make.left.right.equalTo(self.view).equalTo(15);
        
        make.height.equalTo(@50);
        
    }];
    
    return label;
}


#pragma mark --
#pragma mark --设置底部按钮
-(void)setupBottomBtn{
    
    //短信按钮
    UIButton *leftBtn = [self addBtnWithString:@"短信重发"];
    
    [leftBtn mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.view).offset(20);
        
    }];
    
    //取消预约按钮
    UIButton *cancelBtn = [self addBtnWithString:@"取消预约"];
    
    [cancelBtn mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.view).offset(-20);
        
    }];
}

-(UIButton *)addBtnWithString:(NSString *)string{
    
    UIButton *button = [[UIButton alloc]init];
    
    [button setTitle:string forState:UIControlStateNormal];
    
    [button setTitleColor:[UIColor colorWithWhite:0.702 alpha:1.000] forState:UIControlStateNormal];
    
    [button setBackgroundImage:[UIImage imageNamed:@"link_button_02"] forState:UIControlStateNormal];
    
    [self.view addSubview:button];
    
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.view).offset(-15);
        
        make.width.equalTo(@150);
        
        make.height.equalTo(@45);
        
    }];
    
    return button;
}




#pragma mark --
#pragma mark --线
-(void)addLineViewWithTopView:(UIView *)topView{

    UIView *lineView = [[UIView alloc]init];
    
    lineView.backgroundColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    
    [self.view addSubview:lineView];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(topView.mas_bottom);
        
        make.height.equalTo(@1);
        
        make.left.right.equalTo(self.view);
        
    }];

    
    
}





















@end
